package net.content.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;

/**
 * Servlet implementation class ContentFrontController
 */
@WebServlet("*.co")
public class ContentFrontController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		String RequestURI=request.getRequestURI();
		String contextPath=request.getContextPath();
		String command=RequestURI.substring(contextPath.length());
		ActionForward forward=null;
		Action action=null;
		
		if(command.equals("/About.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./about.jsp");
		}else if(command.equals("/Social-icons.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./social-icons.jsp");
		}else if(command.equals("/Icons.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./icons.jsp");
		}else if(command.equals("/Icons-pro.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./icons-pro.jsp");
		}else if(command.equals("/Icons_set2.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./icons_set2.jsp");
		}else if(command.equals("/Typography.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./typography.jsp");
		}else if(command.equals("/Shortcodes.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./shortcodes.jsp");
		}else if(command.equals("/List-styles.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./list-styles.jsp");
		}else if(command.equals("/Charts.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./charts.jsp");
		}else if(command.equals("/Sliders.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./sliders.jsp");
		}else if(command.equals("/Pricing.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./pricing.jsp");
		}else if(command.equals("/Contact.co")){
			forward=new ActionForward();
			forward.setRedirect(false);
			forward.setPath("./contact.jsp");
		}
		
		if(forward!=null){
    		if(forward.isRedirect()){
    			response.sendRedirect(forward.getPath());
    		}else{
    			RequestDispatcher dispatcher=request.getRequestDispatcher(forward.getPath());
    			dispatcher.forward(request, response);
    		}
    	}
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProcess(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doProcess(request, response);
	}

}
